package com.adapter;

import java.util.ArrayList;

import com.hronline.R;
import com.models.ReasonLateness;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import kankan.wheel.widget.adapters.AbstractWheelTextAdapter;

public class ReasonAdapter extends AbstractWheelTextAdapter {

	private ArrayList<ReasonLateness> arrItems;
	
	public ReasonAdapter(Context context, ArrayList<ReasonLateness> arrReasons) {
		super(context, R.layout.reason_item_layout, NO_RESOURCE);
		// TODO Auto-generated constructor stub
		
		this.arrItems	=	arrReasons;
		setItemTextResource(R.id.txtReasonNameItem);
	}
	
	public void setReasonItems(ArrayList<ReasonLateness> arrReasons){
		this.arrItems	=	arrReasons;
	}

	@Override
	public int getItemsCount() {
		// TODO Auto-generated method stub
		
		return this.arrItems.size();
	}

	@Override
	protected CharSequence getItemText(int index) {
		// TODO Auto-generated method stub
		ReasonLateness item	=	this.arrItems.get(index);
		return item.getDescription();
	}
	
	@Override
	public View getItem(int index, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view	=	super.getItem(index, convertView, parent);
		TextView txtReasonName	=	(TextView)view.findViewById(R.id.txtReasonNameItem);
		
		ReasonLateness item	=	this.arrItems.get(index);
		txtReasonName.setText(item.getDescription());
		
		return view;
	}
	
}
